import { Injectable } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { JwtPayLoadDto } from './dto/jwt-payload.dto';
import { IToken } from './interfaces/token.interface';

@Injectable()
export class AuthService {

  constructor(private readonly jwtService: JwtService) { }

  async createToken(jwtPayLoad: JwtPayLoadDto): Promise<IToken> {
    const accessToken = this.jwtService.sign(jwtPayLoad);
    return {
      expiresIn: 3600,
      accessToken
    };
  }

}